import {Component, Input, OnInit, SimpleChanges} from '@angular/core';

@Component({
  selector: 'app-farm-model',
  templateUrl: './farm-model.component.html',
  styleUrls: ['./farm-model.component.css']
})
export class FarmModelComponent implements OnInit {
  /**
   * 风场名称
   *
   * @type {string}@memberof FarmeModelComponent
   */
  @Input()
  farmName: string;
  /**
   * 是否显示太阳
   *
   * @type {boolean}@memberof FarmeModelComponent
   */
  @Input()
  hideSun: boolean;
  /**
   * 风场位置X轴百分比
   *
   * @type {number}@memberof FarmeModelComponent
   */
  @Input()
  farmX: number;
  /**
   * 风场位置Y轴百分比
   *
   * @type {number}@memberof FarmeModelComponent
   */
  @Input()
  farmY: number;
  /**
   * 风速
   *
   * @type {number}@memberof FarmeModelComponent
   */
  @Input()
  windSpeed: number;
  /**
   * 功率
   *
   * @type {number}@memberof FarmeModelComponent
   */
  @Input()
  power: number;
  /**
   * 选中风场下标
   *
   * @type {number}@memberof FarmeModelComponent
   */
  @Input()
  active: number;
  /**
   * 当前风场下标
   *
   * @type {number}@memberof FarmeModelComponent
   */
  @Input()
  i: number;
  speed: number = 0;

  @Input()
  unShowName: boolean;


  constructor() {
  }

  ngOnInit() {
  }

  ngOnChanges(changes: SimpleChanges) {
    if (changes['windSpeed'] && changes['windSpeed'].currentValue) {

      if (this.windSpeed <= 3) {
        this.speed = 0;
      } else if (this.windSpeed > 3 && this.windSpeed <= 5) {
        this.speed = 5;
      } else if (this.windSpeed > 5 && this.windSpeed <= 10) {
        this.speed = 4;
      } else if (this.windSpeed > 10) {
        this.speed = 2;
      }
    }


  }
}
